import apis from '../../http/apis/apis.js'
export default {
    namespaced: "logs",
    state: {
        getLogs: [
            { _id: '1', name: 'zhangsan', time: 'dd', address: '1',operation:'登录',result:'成功' }
        ],
        total: 0,
        pages: 0,
        currentPage: 1,//当前页
        pageSize:2,
    },
    mutations: {
        changelogsData(state, data) {
            state.getLogs = data.get;
            state.total = data.total;
            state.pages = data.pages;
        },
        changePageSize(state, pageSize) {
            state.pageSize = pageSize;
        },
        changeCurrentPage(state, currentPage) {
            state.currentPage = currentPage;
        },


        serialNumber(state) {
            state.getLogs.length
        },
        changeSearchData(state,data){
            state.getLogs=data
            state.total=data.length
        },
        changeCurrentPageToFirst(state){
            state.currentPage=1
        }
    },
    actions: {
        //获取和搜索
        async getLogsdata(context,value) {
            const { data } = await apis.logs.getLogs({
                time:value,
                currentPage: context.state.currentPage,
                pageSize: context.state.pageSize,
            })
            context.commit('changelogsData', data.get);
        },
    }
}